<template>
  <el-container>
    <el-header>
      <el-row :gutter="20">
        <el-button disabled>已放款合同</el-button>
        <el-button type="success" round>
          <router-link to="/contractManage">查看所有合同</router-link>
        </el-button>
        <el-button type="warning" round>
          <router-link to="/LoanManage">查询未放款合同</router-link>
        </el-button>
      </el-row>
    </el-header>
    <el-main>
      <el-table
        border="1"
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        show-header="true"
      >
        <el-table-column prop="empId" label="员工id" width="80">
        </el-table-column>
        <el-table-column prop="product.name" label="产品名称">
        </el-table-column>
        <el-table-column
          prop="user.name"
          label="客户名称"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column prop="number" label="合同编号" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="money" label="贷款金额" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="time" label="贷款时间" show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="loan"
          label="是否放款"
          show-overflow-tooltip
          width="80"
        >
        </el-table-column>
        <el-table-column prop="debt" label="所欠贷款" show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="acceptAccount"
          label="收款账号"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column label="操作" align="center" width="200">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">查看还款情况</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
</template>

<script>
import server from "@/global.js";

export default {
  components: {
    // Repayment,
  },
  data() {
    return {
      tableData: [],
      tableData1:[],
      multipleSelection: [],
      dialogFormVisible: false, //弹出框默认状态
    };
  },
  created: function () {
    //根据当前业务员登录的id和账户查询业务员经手的合同
    this.$axios({
      url: server.server + "/api/contract/selectLoanStatusIsN",
      //   url: "http://localhost:8080/api/contract/selectLoanStatusIsN",
      method: "post",
      data: {
        emp: {
          id: 1,
          account: "admin",
        },
        status: "y",
      },
    }).then((r) => {
      if (r.data.code == 200) {
        this.tableData = r.data.data;
      } else {
        window.alert(r.data.message);
      }
    });
  },
  methods: {
    //查款还款情况
    handleEdit(index, row) {
      console.log(row);
      this.$router.push({path:'/repayment',query:{conId:row.id}}) 
    },
    //执行合同更新操作
    // updateContract: function () {
    //   if (this.form.loan == "y") {
    //     window.alert("当前合同已经放款，不能进行更新");
    //   } else {
    //     //执行更改
    //     this.$axios({
    //       url: server.server + "/api/contract/update",
    //       method: "post",
    //       data: this.form,
    //     }).then((r) => {
    //       if (r.data.code == 200) {
    //         window.alert("修改成功");
    //       } else {
    //         window.alert(r.data.message);
    //       }
    //     });
    //   }
    //   console.log(this.form);
    // },
  },
};
</script>

<style>
.el-row {
  margin-bottom: 20px;
}
.el-row > el-col:last-child {
  margin-bottom: 20px;
  margin-bottom: 0;
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.grid-content.bg-purple {
  text-align: center;
}
</style>